<?php

namespace app\admin\model\books;

use think\Model;


class Browse extends Model
{
    // 表名
    protected $name = 'browse';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'bigint';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
    ];

    public function getInfo($where){
        return $this->where($where)->with('book,user')->find();
    }
    public function getList($where){
        return $this->where($where)->with(['book'])->order('updatetime desc')->select();
    }
    public function book()
    {
        return $this->belongsTo('app\admin\model\Books', 'book_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }

    public function user()
    {
        return $this->belongsTo('app\admin\model\User', 'uid', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
